﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace DailyFx.Book.Repo
{

	public class CsvRecord : IEnumerable<string>
	{
		/// <summary>
		///		Contains the schema of the data row .
		/// </summary>
	//	private readonly Schema _schema;

		/// <summary>
		///		Contains the values of the row .
		/// </summary>
		private readonly string[] _values;


		/// <summary>
		///		c'tor .
		/// </summary>
		public CsvRecord ( IList<string> values )
		{ 
			this._values = new string [values.Count];
			
			int i = 0;
			foreach ( var v in values )
			{
				this._values[i] = v;
				i++;
			}
		}

		/// <summary>
		///		Gets a string value in this record by index.
		/// </summary>
		public string this [ int index ]
		{
			get
			{
				return (String)_values[index];
			}
		}

		/// <inheritdoc/>
		IEnumerator<string> IEnumerable<string>.GetEnumerator()
		{
			foreach (var v in _values)
			{
				yield return (String)v;
			}
		}

		/// <inheritdoc/>
		System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
		{
			return _values.GetEnumerator();
		}
	}
}
